package org.zenheart.fxnative.view.controller;

import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TabPane;
import javafx.scene.layout.AnchorPane;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.net.URL;
import java.util.ResourceBundle;

@Slf4j
@Component
public class DesktopController implements Initializable {

    @FXML
    public AnchorPane desktopContainer;
    @FXML
    public TabPane tabPane;
    @FXML
    private SettingController settingController;
    @FXML
    private TableListController tableListController;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        tableListController.tableContainer.setPrefWidth(desktopContainer.getWidth());
        tableListController.tableContainer.prefWidthProperty().bind(desktopContainer.widthProperty());

        tableListController.tableContainer.setPrefHeight(desktopContainer.getHeight());
        tableListController.tableContainer.prefHeightProperty().bind(desktopContainer.heightProperty());

        tabPane.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
            log.info("================: {}", oldValue);
        });
    }

    public void switchClick(Event event) {
    }
}
